package com.aries.remoteplusserver.core;

import java.io.IOException;

public class PowerHandler {

	private Runtime runTime;
	private Process process;
	
	public PowerHandler()
	{
		this.runTime = Runtime.getRuntime();
	}
	
	public void powerHandler(Object[] args) throws IOException
	{
		String command  = args[0].toString();
		String sysCommand = "";
		
		if ( command.equals("Lock") )
		{
			sysCommand = "cmd /c rundll32.exe user32.dll,LockWorkStation";
		}
		else if ( command.equals("Hibernate") )
		{
			sysCommand = "shutdown -h";
		}
		else if ( command.equals("ShutDown") )
		{
			sysCommand = "shutdown -s";
		}
		else if ( command.equals("Abort") )
		{
			
		}
		else if ( command.equals("Log Off") )
		{
			sysCommand = "logoff";
		}
		else if ( command.equals("Sleep") )
		{
			sysCommand = "cmd /c rundll32.exe powrprof.dll,SetSuspendState";
		}
		else if ( command.equals("Restart") )
		{
			sysCommand = "shutdown -r";
		}
		
		if ( !sysCommand.equals("") )
		{
			this.process = runTime.exec(sysCommand);
		}
	}
}
